<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>libwebsockets: Notes about building lws</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="libwebsockets.org-logo.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">libwebsockets
   </div>
   <div id="projectbrief">Lightweight C library for HTML5 websockets</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li class="current"><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('md_README.build.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">Notes about building lws </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><h1><a class="anchor" id="cm"></a>
Introduction to CMake</h1>
<p>CMake is a multi-platform build tool that can generate build files for many different target platforms. See more info at <a href="http://www.cmake.org">http://www.cmake.org</a></p>
<p>CMake also allows/recommends you to do "out of source"-builds, that is, the build files are separated from your sources, so there is no need to create elaborate clean scripts to get a clean source tree, instead you simply remove your build directory.</p>
<p>Libwebsockets has been tested to build successfully on the following platforms with SSL support (both OpenSSL/wolfSSL):</p>
<ul>
<li>Windows (Visual Studio)</li>
<li>Windows (MinGW)</li>
<li>Linux (x86 and ARM)</li>
<li>OSX</li>
<li>NetBSD</li>
</ul>
<h1><a class="anchor" id="build1"></a>
Building the library and test apps</h1>
<p>The project settings used by CMake to generate the platform specific build files is called <a href="CMakeLists.txt">CMakeLists.txt</a>. CMake then uses one of its "Generators" to output a Visual Studio project or Make file for instance. To see a list of the available generators for your platform, simply run the "cmake" command.</p>
<p>Note that by default OpenSSL will be linked, if you don't want SSL support see below on how to toggle compile options.</p>
<h1><a class="anchor" id="bu"></a>
Building on Unix:</h1>
<ol type="1">
<li>Install CMake 2.8 or greater: <a href="http://cmake.org/cmake/resources/software.html">http://cmake.org/cmake/resources/software.html</a> (Most Unix distributions comes with a packaged version also)</li>
<li>Install OpenSSL.</li>
<li>Generate the build files (default is Make files): <div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;$ cd /path/to/src</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;$ mkdir build</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;$ cd build</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;$ cmake ..</div></div><!-- fragment --></li>
<li>Finally you can build using the generated Makefile: <div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;$ make &amp;&amp; sudo make install</div></div><!-- fragment --> <b>NOTE</b>: The <code>build/</code><code>directory can have any name and be located anywhere on your filesystem, and that the argument</code>..` given to cmake is simply the source directory of <b>libwebsockets</b> containing the <a href="CMakeLists.txt">CMakeLists.txt</a> project file. All examples in this file assumes you use ".."</li>
</ol>
<p><b>NOTE2</b>: A common option you may want to give is to set the install path, same as &ndash;prefix= with autotools. It defaults to /usr/local. You can do this by, eg </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;$ cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr .</div></div><!-- fragment --><p><b>NOTE3</b>: On machines that want libraries in lib64, you can also add the following to the cmake line </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;-DLIB_SUFFIX=64</div></div><!-- fragment --><p><b>NOTE4</b>: If you are building against a non-distro OpenSSL (eg, in order to get access to ALPN support only in newer OpenSSL versions) the nice way to express that in one cmake command is eg, </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;$ cmake .. -DOPENSSL_ROOT_DIR=/usr/local/ssl \</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;         -DCMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE=/usr/local/ssl \</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;         -DLWS_WITH_HTTP2=1</div></div><!-- fragment --><p>When you run the test apps using non-distro SSL, you have to force them to use your libs, not the distro ones </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;$ LD_LIBRARY_PATH=/usr/local/ssl/lib libwebsockets-test-server --ssl</div></div><!-- fragment --><p>To get it to build on latest openssl (2016-04-10) it needed this approach </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;cmake .. -DLWS_WITH_HTTP2=1 -DLWS_OPENSSL_INCLUDE_DIRS=/usr/local/include/openssl -DLWS_OPENSSL_LIBRARIES=&quot;/usr/local/lib64/libssl.so;/usr/local/lib64/libcrypto.so&quot;</div></div><!-- fragment --><p><b>NOTE5</b>: To build with debug info and _DEBUG for lower priority debug messages compiled in, use </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;$ cmake .. -DCMAKE_BUILD_TYPE=DEBUG</div></div><!-- fragment --><p><b>NOTE6</b> To build on Solaris the linker needs to be informed to use lib socket and libnsl, and only builds in 64bit mode.</p>
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;$ cmake .. -DCMAKE_C_FLAGS=-m64 -DCMAKE_EXE_LINKER_FLAGS=&quot;-lsocket -lnsl&quot;</div></div><!-- fragment --><ol type="1">
<li>Finally you can build using the generated Makefile:</li>
</ol>
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;$ make</div></div><!-- fragment --><h1><a class="anchor" id="cmq"></a>
Quirk of cmake</h1>
<p>When changing cmake options, for some reason the only way to get it to see the changes sometimes is delete the contents of your build directory and do the cmake from scratch.</p>
<h1><a class="anchor" id="cmw"></a>
Building on Windows (Visual Studio)</h1>
<ol type="1">
<li>Install CMake 2.6 or greater: <a href="http://cmake.org/cmake/resources/software.html">http://cmake.org/cmake/resources/software.html</a></li>
<li><p class="startli">Install OpenSSL binaries. <a href="http://www.openssl.org/related/binaries.html">http://www.openssl.org/related/binaries.html</a></p>
<p class="startli">(<b>NOTE</b>: Preferably in the default location to make it easier for CMake to find them)</p>
<p class="startli"><b>NOTE2</b>: Be sure that OPENSSL_CONF environment variable is defined and points at &lt;OpenSSL install="" location&gt;=""&gt;.cfg</p>
</li>
<li>Generate the Visual studio project by opening the Visual Studio cmd prompt:</li>
</ol>
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;cd &lt;path to src&gt;</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;md build</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;cd build</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;cmake -G &quot;Visual Studio 10&quot; ..</div></div><!-- fragment --><p>(<b>NOTE</b>: There is also a cmake-gui available on Windows if you prefer that)</p>
<p><b>NOTE2</b>: See this link to find out the version number corresponding to your Visual Studio edition: <a href="http://superuser.com/a/194065">http://superuser.com/a/194065</a></p>
<ol type="1">
<li>Now you should have a generated Visual Studio Solution in your <code>&lt;path to src&gt;/build</code> directory, which can be used to build.</li>
<li>Some additional deps may be needed<ul>
<li>iphlpapi.lib</li>
<li>psapi.lib</li>
<li>userenv.lib</li>
</ul>
</li>
<li>If you're using libuv, you must make sure to compile libuv with the same multithread-dll / Mtd attributes as libwebsockets itself</li>
</ol>
<h1><a class="anchor" id="cmwmgw"></a>
Building on Windows (MinGW)</h1>
<ol type="1">
<li><p class="startli">Install MinGW: <a href="http://sourceforge.net/projects/mingw/files">http://sourceforge.net/projects/mingw/files</a></p>
<p class="startli">(<b>NOTE</b>: Preferably in the default location C:)</p>
</li>
<li><p class="startli">Fix up MinGW headers</p>
<p class="startli">a) Add the following lines to C:.h: </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;#if(_WIN32_WINNT &gt;= 0x0600)</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;typedef struct pollfd {</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;</div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;        SOCKET  fd;</div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;        SHORT   events;</div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;        SHORT   revents;</div><div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;</div><div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;} WSAPOLLFD, *PWSAPOLLFD, FAR *LPWSAPOLLFD;</div><div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;</div><div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;WINSOCK_API_LINKAGE int WSAAPI WSAPoll(LPWSAPOLLFD fdArray, ULONG fds, INT timeout);</div><div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;</div><div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;#endif // (_WIN32_WINNT &gt;= 0x0600)</div></div><!-- fragment --><p> b) Create C:.h and copy and paste the content from following link into it:</p>
<p class="startli"><a href="http://wine-unstable.sourcearchive.com/documentation/1.1.32/mstcpip_8h-source.html">http://wine-unstable.sourcearchive.com/documentation/1.1.32/mstcpip_8h-source.html</a></p>
</li>
<li>Install CMake 2.6 or greater: <a href="http://cmake.org/cmake/resources/software.html">http://cmake.org/cmake/resources/software.html</a></li>
<li><p class="startli">Install OpenSSL binaries. <a href="http://www.openssl.org/related/binaries.html">http://www.openssl.org/related/binaries.html</a></p>
<p class="startli">(<b>NOTE</b>: Preferably in the default location to make it easier for CMake to find them)</p>
<p class="startli"><b>NOTE2</b>: Be sure that OPENSSL_CONF environment variable is defined and points at &lt;OpenSSL install="" location&gt;=""&gt;.cfg</p>
</li>
<li><p class="startli">Generate the build files (default is Make files) using MSYS shell: </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;$ cd /drive/path/to/src</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;$ mkdir build</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;$ cd build</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;$ cmake -G &quot;MSYS Makefiles&quot; -DCMAKE_INSTALL_PREFIX=C:/MinGW ..</div></div><!-- fragment --><p> (<b>NOTE</b>: The <code>build/</code><code>directory can have any name and be located anywhere on your filesystem, and that the argument</code>..` given to cmake is simply the source directory of <b>libwebsockets</b> containing the <a href="CMakeLists.txt">CMakeLists.txt</a> project file. All examples in this file assumes you use "..")</p>
<p class="startli"><b>NOTE2</b>: To generate build files allowing to create libwebsockets binaries with debug information set the CMAKE_BUILD_TYPE flag to DEBUG: </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;$ cmake -G &quot;MSYS Makefiles&quot; -DCMAKE_INSTALL_PREFIX=C:/MinGW -DCMAKE_BUILD_TYPE=DEBUG ..</div></div><!-- fragment --></li>
<li>Finally you can build using the generated Makefile and get the results deployed into your MinGW installation:</li>
</ol>
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;$ make</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;$ make install</div></div><!-- fragment --><h1><a class="anchor" id="mbed3"></a>
Building on mbed3</h1>
<p>MBED3 is a non-posix embedded OS targeted on Cortex M class chips.</p>
<p><a href="https://www.mbed.com/">https://www.mbed.com/</a></p>
<p>It's quite unlike any other Posixy platform since the OS is linked statically in with lws to form one binary.</p>
<p>At the minute server-only is supported and due to bugs in mbed3 network support, the port is of alpha quality. However it can serve the test html, favicon.ico and logo png and may be able to make ws connections. The binary for that including the OS, test app, lws and all the assets is only 117KB.</p>
<p>0) Today mbed3 only properly works on FRDM K64F $35 Freescale Dev Board with 1MB Flash, 256KB SRAM and Ethernet.</p>
<p><a href="http://www.freescale.com/products/arm-processors/kinetis-cortex-m/k-series/k6x-ethernet-mcus/freescale-freedom-development-platform-for-kinetis-k64-k63-and-k24-mcus:FRDM-K64F">http://www.freescale.com/products/arm-processors/kinetis-cortex-m/k-series/k6x-ethernet-mcus/freescale-freedom-development-platform-for-kinetis-k64-k63-and-k24-mcus:FRDM-K64F</a></p>
<p>1) Get a working mbed3 environment with arm-none-eabi-cs toolchain (available in Fedora, Ubuntu and other distros)</p>
<p>2) Confirm you can build things using yotta by following the getting started guide here</p>
<p><a href="https://docs.mbed.com/docs/getting-started-mbed-os/en/latest/">https://docs.mbed.com/docs/getting-started-mbed-os/en/latest/</a></p>
<p>3)</p>
<p>git clone <a href="https://github.com/warmcat/lws-test-server">https://github.com/warmcat/lws-test-server</a></p>
<p>and cd into it</p>
<p>4) mkdir -p yotta_modules ; cd yotta_modules</p>
<p>5) git clone <a href="https://github.com/warmcat/libwebsockets">https://github.com/warmcat/libwebsockets</a> ; mv libwebsockets websockets ; cd ..</p>
<p>6) yotta target frdm-k64f-gcc</p>
<p>7) yotta install</p>
<p>8) yotta build</p>
<h1><a class="anchor" id="cmco"></a>
Setting compile options</h1>
<p>To set compile time flags you can either use one of the CMake gui applications or do it via the command line.</p>
<h2><a class="anchor" id="cmcocl"></a>
Command line</h2>
<p>To list available options (omit the H if you don't want the help text): </p><pre class="fragment">    cmake -LH ..
</pre><p>Then to set an option and build (for example turn off SSL support): </p><pre class="fragment">    cmake -DLWS_WITH_SSL=0 ..
</pre><p> or cmake -DLWS_WITH_SSL:BOOL=OFF ..</p>
<h2><a class="anchor" id="cmcoug"></a>
Unix GUI</h2>
<p>If you have a curses-enabled build you simply type: (not all packages include this, my debian install does not for example). </p><pre class="fragment">    ccmake
</pre><h2><a class="anchor" id="cmcowg"></a>
Windows GUI</h2>
<p>On windows CMake comes with a gui application: Start -&gt; Programs -&gt; CMake -&gt; CMake (cmake-gui)</p>
<h1><a class="anchor" id="wolf"></a>
wolfSSL/CyaSSL replacement for OpenSSL</h1>
<p>wolfSSL/CyaSSL is a lightweight SSL library targeted at embedded systems: <a href="https://www.wolfssl.com/wolfSSL/Products-wolfssl.html">https://www.wolfssl.com/wolfSSL/Products-wolfssl.html</a></p>
<p>It contains a OpenSSL compatibility layer which makes it possible to pretty much link to it instead of OpenSSL, giving a much smaller footprint.</p>
<p><b>NOTE</b>: wolfssl needs to be compiled using the <code>--enable-opensslextra</code> flag for this to work.</p>
<h1><a class="anchor" id="wolf1"></a>
Compiling libwebsockets with wolfSSL</h1>
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;cmake .. -DLWS_USE_WOLFSSL=1 \</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;         -DLWS_WOLFSSL_INCLUDE_DIRS=/path/to/wolfssl \</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;         -DLWS_WOLFSSL_LIBRARIES=/path/to/wolfssl/wolfssl.a ..</div></div><!-- fragment --><p><b>NOTE</b>: On windows use the .lib file extension for <code>LWS_WOLFSSL_LIBRARIES</code> instead.</p>
<h1><a class="anchor" id="cya"></a>
Compiling libwebsockets with CyaSSL</h1>
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;cmake .. -DLWS_USE_CYASSL=1 \</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;         -DLWS_CYASSL_INCLUDE_DIRS=/path/to/cyassl \</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;         -DLWS_CYASSL_LIBRARIES=/path/to/wolfssl/cyassl.a ..</div></div><!-- fragment --><p><b>NOTE</b>: On windows use the .lib file extension for <code>LWS_CYASSL_LIBRARIES</code> instead.</p>
<h1><a class="anchor" id="extplugins"></a>
Building plugins outside of lws itself</h1>
<p>The directory ./plugin-standalone/ shows how easy it is to create plugins outside of lws itself. First build lws itself with -DLWS_WITH_PLUGINS, then use the same flow to build the standalone plugin </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;cd ./plugin-standalone</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;mkdir build</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;cd build</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;cmake ..</div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;make &amp;&amp; sudo make install</div></div><!-- fragment --><p>if you changed the default plugin directory when you built lws, you must also give the same arguments to cmake here (eg, <code>-DCMAKE_INSTALL_PREFIX:PATH=/usr/something/else...</code> )</p>
<p>Otherwise if you run lwsws or libwebsockets-test-server-v2.0, it will now find the additional plugin "libprotocol_example_standalone.so" </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;lwsts[21257]:   Plugins:</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;lwsts[21257]:    libprotocol_dumb_increment.so</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;lwsts[21257]:    libprotocol_example_standalone.so</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;lwsts[21257]:    libprotocol_lws_mirror.so</div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;lwsts[21257]:    libprotocol_lws_server_status.so</div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;lwsts[21257]:    libprotocol_lws_status.so</div></div><!-- fragment --><p> If you have multiple vhosts, you must enable plugins at the vhost additionally, discovered plugins are not enabled automatically for security reasons. You do this using info-&gt;pvo or for lwsws, in the JSON config.</p>
<h1><a class="anchor" id="http2rp"></a>
Reproducing HTTP2.0 tests</h1>
<p>You must have built and be running lws against a version of openssl that has ALPN / NPN. Most distros still have older versions. You'll know it's right by seeing </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;lwsts[4752]:  Compiled with OpenSSL support</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;lwsts[4752]:  Using SSL mode</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;lwsts[4752]:  HTTP2 / ALPN enabled</div></div><!-- fragment --><p> at lws startup.</p>
<p>For non-SSL HTTP2.0 upgrade </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;$ nghttp -nvasu http://localhost:7681/test.htm</div></div><!-- fragment --><p> For SSL / ALPN HTTP2.0 upgrade </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;$ nghttp -nvas https://localhost:7681/test.html</div></div><!-- fragment --><h1><a class="anchor" id="cross"></a>
Cross compiling</h1>
<p>To enable cross-compiling <b>libwebsockets</b> using CMake you need to create a "Toolchain file" that you supply to CMake when generating your build files. CMake will then use the cross compilers and build paths specified in this file to look for dependencies and such.</p>
<p><b>Libwebsockets</b> includes an example toolchain file <a href="cross-arm-linux-gnueabihf.cmake">cross-arm-linux-gnueabihf.cmake</a> you can use as a starting point.</p>
<p>The commandline to configure for cross with this would look like </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;$ cmake .. -DCMAKE_INSTALL_PREFIX:PATH=/usr \</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;         -DCMAKE_TOOLCHAIN_FILE=../cross-arm-linux-gnueabihf.cmake \</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;         -DWITHOUT_EXTENSIONS=1 -DWITH_SSL=0</div></div><!-- fragment --><p> The example shows how to build with no external cross lib dependencies, you need to provide the cross libraries otherwise.</p>
<p><b>NOTE</b>: start from an EMPTY build directory if you had a non-cross build in there before the settings will be cached and your changes ignored.</p>
<p>Additional information on cross compilation with CMake: <a href="http://www.vtk.org/Wiki/CMake_Cross_Compiling">http://www.vtk.org/Wiki/CMake_Cross_Compiling</a></p>
<h1><a class="anchor" id="mem"></a>
Memory efficiency</h1>
<p>Embedded server-only configuration without extensions (ie, no compression on websocket connections), but with full v13 websocket features and http server, built on ARM Cortex-A9:</p>
<p>Update at 8dac94d (2013-02-18) </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;$ ./configure --without-client --without-extensions --disable-debug --without-daemonize</div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;Context Creation, 1024 fd limit[2]:   16720 (includes 12 bytes per fd)</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;Per-connection [3]:                      72 bytes, +1328 during headers</div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;</div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;.text   .rodata .data   .bss</div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;11512   2784    288     4</div></div><!-- fragment --><p> This shows the impact of the major configuration with/without options at 13ba5bbc633ea962d46d using Ubuntu ARM on a PandaBoard ES.</p>
<p>These are accounting for static allocations from the library elf, there are additional dynamic allocations via malloc. These are a bit old now but give the right idea for relative "expense" of features.</p>
<p>Static allocations, ARM9</p>
<table class="doxtable">
<tr>
<th></th><th>.text </th><th>.rodata </th><th>.data </th><th>.bss  </th></tr>
<tr>
<td>All (no without) </td><td>35024 </td><td>9940 </td><td>336 </td><td>4104 </td></tr>
<tr>
<td>without client </td><td>25684 </td><td>7144 </td><td>336 </td><td>4104 </td></tr>
<tr>
<td>without client, exts </td><td>21652 </td><td>6288 </td><td>288 </td><td>4104 </td></tr>
<tr>
<td>without client, exts, debug[1] </td><td>19756 </td><td>3768 </td><td>288 </td><td>4104 </td></tr>
<tr>
<td>without server </td><td>30304 </td><td>8160 </td><td>336 </td><td>4104 </td></tr>
<tr>
<td>without server, exts </td><td>25382 </td><td>7204 </td><td>288 </td><td>4104 </td></tr>
<tr>
<td>without server, exts, debug[1] </td><td>23712 </td><td>4256 </td><td>288 </td><td>4104 </td></tr>
</table>
<p>[1] <code>--disable-debug</code> only removes messages below <code>lwsl_notice</code>. Since that is the default logging level the impact is not noticeable, error, warn and notice logs are all still there.</p>
<p>[2] <code>1024</code> fd per process is the default limit (set by ulimit) in at least Fedora and Ubuntu. You can make significant savings tailoring this to actual expected peak fds, ie, at a limit of <code>20</code>, context creation allocation reduces to <code>4432 + 240 = 4672</code>)</p>
<p>[3] known header content is freed after connection establishment </p>
</div></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.11 </li>
  </ul>
</div>
</body>
</html>
